package com.kitbox.hl.meshow.bpm.utils;


import java.util.List;
import java.util.Map;

public class BpmTest {

    public static void main(String[] args) {
        String url="http://192.168.0.110:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="getProcessInstState";
        Object[] obj=new Object[]{"",8165};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        String status = ClientUtils.xmlElementsReturnString(resultXml);
        System.out.println("创建流程实例状态——》流程实例ID:"+status);


      /* String url="http://192.168.0.110:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryWorkItemsAndReviewByProcessInstId";
        Object[] obj=new Object[]{6083L,true};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        List<Map<String,String>> list = ClientUtils.xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/


    /*    String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="assignAndFinishWorkItemWithOption";
        Object[] obj=new Object[]{"2c9082e861f514040162222252a2007f","5200","",false};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        System.out.println(resultXml);
*/

     /*String url="http://172.16.2.87:8099/default/services/WSDefinitionQueryManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSDefinitionQueryManagerService";
        String method="getProcess";
        Object[] obj=new Object[]{"2c9082e861f514040162222252a2007f","4021"};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);*/
       // String flowId = ClientUtils.xmlElementsReturnString(resultXml);;
       // System.out.print(resultXml);
        /*List<LinkedHashMap<String,String>> list = ClientUtils.xmlElementsReturnList1(resultXml);
        for(LinkedHashMap<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/
        try {
            //ClientUtils.XmlExam(resultXml);
            //JSONObject json=XmlUtil.xml2JSON(resultXml.getBytes());
            //System.out.println(json.toJSONString());

            //Object r = json.get("userTask");
           // System.out.println(r);



        } catch (Exception e) {
            e.printStackTrace();
        }

        //System.out.println(resultXml);

       /* String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryBacklogAndFinishWorkItemsByProcessInstId";
        Object[] obj=new Object[]{5090,false};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        List<Map<String,String>> list = ClientUtils.xmlElementsReturnList(resultXml);
        List<BPMWorkItem> wList= new ArrayList<>();
        for(Map<String,String> map:list) {
            BPMWorkItem workItem=new BPMWorkItem();
            EntityMappingUtil.copyProperites(workItem,map);
            wList.add(workItem);
        }*/
      //  return wList;

        //创建并启动流程【用户ID、流程定义名称、流程实例名称、流程实例描述、是否启动】  返回实例ID,  只有一个值 Key:out1
       /* String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="createProcessInstance";
        Object[] obj=new Object[]{"leave","LeaveFlow","20180521Loan09","请假流程》=3天",true};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        String flowId = ClientUtils.xmlElementsReturnString(resultXml);;
        System.out.println(flowId);*/


        //查询待办工作项【用户ID、参与者ID、执行权限、任务来源】
        //执行权限ALL(全部)|PUBLIC(公共)|PRIVATE(个人)(PUBLIC,PRIVATE可以形成组合)用逗号隔开
        //任务来源ALL(全部)|SELF(自己)|AGENT(代理)|DELEG(代办)|HELP(协办)(SELF,AGENT,DELEG,HELP可以形成组合)用逗号隔开
        //返回WorkItems 列表
    /*String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryPersonWorkItems";
        Object[] obj=new Object[]{"mjs","2c9082e8634d55eb016361bfd26c01da","ALL","ALL"};
        String resultXml = client(url,nameSpace,method,obj);
        List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        //查询指定人员完成的工作项【用户ID、参与者ID、任务来源、是否包含历史表】
        //任务来源ALL(全部)|SELF(自己)|AGENT(代理)|DELEG(代办)|HELP(协办)(SELF,AGENT,DELEG,HELP可以形成组合)用逗号隔开
        //返回WorkItems 列表
        /*String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryPersonFinishedWorkItems";
        Object[] obj=new Object[]{"mjs","2c9082e861f514040162222252a2007f","ALL",true};
        String resultXml = client(url,nameSpace,method,obj);
        List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/



    /*    //签收工作项【用户ID、工作项ID】  返回执行结果，0表示成功，-1失败,  只有一个值 Key:out1
        String url="http://172.16.2.87:8099/default/services/WSActivityInstManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSActivityInstManagerService";
        String method="changeActivityInstState";
        Object[] obj=new Object[]{"mjs",6312L};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        String flowId = ClientUtils.xmlElementsReturnString(resultXml);
        System.out.println(flowId);*/

        //指派后继活动的参与者【用户ID、工作项ID、活动定义ID、参与者列表（WFParticipant[]）】
       /* String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="appointActivityParticipant";
        WFParticipant w=new WFParticipant("yanxiao@qq.com","2c9082e8634d55eb016361bfd26c01da","yxn","02");

       String xml= "<?xml version='1.0'encoding='UTF8'>"+
       "<list>"+
        "<Participant>"+
        "<id>2c9082e8634d55eb016361bfd26c01da</id>"+
        "<name>yxn</name>"+
        " <type>01</type>"+
        " </Participant>"+
        "</list>";
        Object[] obj=new Object[]{"leave",2028L,"UserTask",w};
        String resultXml = client(url,nameSpace,method,obj);
        System.out.println(resultXml);*/


        //完成活动实例【用户ID、工作项ID、相关数据列表、是否需要校验权限】  返回执行结果，0表示成功，-1失败,  只有一个值 Key:out1
       /*String url1="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace1="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method1="finishWorkItemWithOption";

        BPMFinishOption d = new BPMFinishOption();
        Map<String,String> map=new HashMap<String,String>();
        map.put("isAgree","Y");
        d.setRelativeData(map);
        d.setCheckPermission(true);

        Object[] obj1=new Object[]{"mjs",2035L,"day:3",false};
        String resultXml1 = client(url1,nameSpace1,method1,obj1);
        System.out.println(resultXml1);*/

        //批量改派 指定参与者【用户ID、JSON数据】 //2c9082e861f514040162222252a2007f
 /*String url="http://172.16.2.87:8099/default/services/WShttp://127.0.0.1:8099InterfaceManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSBatchInterfaceManagerService";
        String method="batchReassignWorkItem";
        String json="[\n" +
                "  {\n" +
                "    \"personID\":\"2c9082e8634d55eb016361bfd26c01da\",\n" +
                "    \"workItemID\":2036\n" +
                "  }\n" +
                "]";
        Object[] obj=new Object[]{"mjs",json};
        String resultXml = client(url,nameSpace,method,obj);
        System.out.println(resultXml);*/

        /*String url="http://172.16.2.87:8099/default/services/WSWorkItemManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSWorkItemManagerService";
        String method="reassignWorkItem";
        Object[] obj=new Object[]{"mjs",2036L,"2c9082e861f514040162222252a2007f"};
        String resultXml = client(url,nameSpace,method,obj);
        System.out.println(resultXml);*/



        //完成活动实例【用户ID、活动实例ID】  返回执行结果 无
        /*String url="http://172.16.2.87:8099/default/services/WSActivityInstManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSActivityInstManagerService";
        String method="finishActivityInstance";
        Object[] obj=new Object[]{"mjs",2030L};
        client(url,nameSpace,method,obj);
        System.out.println("处理成功");*/

        //回退活动实例【用户ID、活动实例ID、目标活动实例ID、回退策略】  返回执行结果 无
        //回退策略：
        //path （基于两点间的路径回退）
        //recent_manual （回退到最近的人工活动）
        //one_step （单步回退）
        //simple （简单回退）
        /*String url="http://172.16.2.87:8099/default/services/WSBackActivityManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSBackActivityManagerService";
        String method="backActivity";
        Object[] obj=new Object[]{"mjs",6647L,6646L,"one_step"};
        ClientUtils.client(url,nameSpace,method,obj);
        System.out.println("处理成功");*/


       /* String url="http://172.16.2.87:8099/default/services/WSBackActivityManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSBackActivityManagerService";
        String method="backDefActivity";
        Object[] obj=new Object[]{"mjs",6348L,"UserTask1","one_step"};
        ClientUtils.client(url,nameSpace,method,obj);
        System.out.println("处理成功");*/


       /* String url="http://172.16.2.87:8099/default/services/WSActivityInstManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSActivityInstManagerService";
        //String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
       // String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";

        String method="queryPreviousActivityInstances";
        Object[] obj=new Object[]{"mjs",6348L};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        System.out.println(resultXml);
        List<Map<String,String>> list =  ClientUtils.xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }
*/

   /*     String url="http://172.16.2.87:8099/default/services/WSDefinitionQueryManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSDefinitionQueryManagerService";
        String method="queryPreviousActivities";
        Object[] obj=new Object[]{"mjs",2022L,"UserTask1"};
        String resultXml = ClientUtils.client(url,nameSpace,method,obj);
        System.out.println(resultXml);
        List<Map<String,String>> list =  ClientUtils.xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        //完成某个流程实例下的某个活动定义对应的活动实例【用户ID、流程实例ID、活动定义ID】  无返回值
//       String url="http://172.16.2.87:8099/default/services/WSActivityInstManagerService?wsdl";
//        String nameSpace="http://www.primeton.com/services/WSActivityInstManagerService";
//        String method="finishActivityInstByActivityID";
//        Object[] obj=new Object[]{"mjs",2022L,"UserTask1"};
//        String resultXml = client(url,nameSpace,method,obj);
//        System.out.println(resultXml);





        //根据流程实例id查询工作项的信息【流程实例id、是否包含历史表】  返回XML格式的String,  只有一个值 Key:out1
        /*String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryWorkItemsAndReviewByProcessInstId";
        Object[] obj=new Object[]{2028L,true};
        String resultXml = client(url,nameSpace,method,obj);
        List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        //查询
       /* String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryWorkItemsAndReviewByProcessInstId";
        Object[] obj=new Object[]{2028L,true};
        String resultXml = client(url,nameSpace,method,obj);
        List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        //查询 流程实例处理列表
        /*String url="http://172.16.2.87:8099/default/services/SimpleParameterProcessLifecycleService?wsdl";
        String nameSpace="http://www.primeton.com/services/SimpleParameterProcessLifecycleService";
        String method="queryBacklogAndFinishWorkItemsByProcessInstId";
        Object[] obj=new Object[]{2029L,true};
        String resultXml = client(url,nameSpace,method,obj);
        List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        /**
         * 根据当前活动实例ID计算将要流转到的直接后继活动 【用户ID 当前活动实例ID】
         */
     /*   String url="http://172.16.2.87:8099/default/services/WSDefinitionQueryManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSDefinitionQueryManagerService";
        String method="queryNextActivitesNeedAppointParticipant";
        Object[] obj=new Object[]{"yxn",2036L};
        String resultXml = client(url,nameSpace,method,obj);
        System.out.println(resultXml);*/
       /* List<Map<String,String>> list = xmlElementsReturnList(resultXml);
        for(Map<String,String> map:list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("key："+entry.getKey()+"   vaule："+entry.getValue());
            }
        }*/

        //根据【用户、工作项ID】  获取流程实例信息
        /*String url="http://172.16.2.87:8099/default/services/WSWorkItemManagerService?wsdl";
        String nameSpace="http://www.primeton.com/services/WSWorkItemManagerService";
        String method="queryWorkItemDetail";
        Object[] obj=new Object[]{"mjs",1};
        BPMWorkItem workItem=new BPMWorkItem();
        client(url,nameSpace,method,obj,workItem);*/


    }

}
